package ee.ut.aa.neuraltic.genetic;

import java.util.Comparator;

import ee.ut.aa.neuraltic.neural.Network;

public class NetworkComparator implements Comparator<Network> {

	@Override
	public int compare( Network netOne, Network netTwo ) {

		// It is reversed to optimize sorting
		
		// Natural selection... older networks disappear
		if( netOne.getGeneration() > 6 )
			return 1;
		if( netTwo.getGeneration() > 6 )
			return 1;

		if( netOne.getValue() > netTwo.getValue() )
			return -1;
		if( netOne.getValue() < netTwo.getValue() )
			return 1;

		return 0;
	}
}
